package com.seaengine.actor.anibmp.characterbmp
{
	import flash.geom.Rectangle;
	import com.seaengine.actor.anibmp.BaseBmpMgr;
	import com.seaengine.actor.anibmp.BaseBmpNodeInfo;
	
	
	public class CharacterBmpMgr extends BaseBmpMgr
	{
		private var m_AnimNodeInfos:Object;
		public var m_hotErea:Rectangle;
		public var m_WeaponXML:String;
		public var m_EffectSWF:String;
		public var arrNormalAttackGroup:Array =new Array(0,0,0,0,0,0,0,0,0,0);
		public function CharacterBmpMgr(_id:int,_xml:XML,_SuccessFn:Function)
		{
			
			m_AnimNodeInfos = new Object();			
			m_hotErea = new Rectangle(_xml.@hotEreaX,_xml.@hotEreaY,_xml.@hotWidth,_xml.@hotHeight);
			m_WeaponXML = _xml.@weaponXML;
			m_EffectSWF = _xml.@effectSWF;
			super(_id,_xml,_SuccessFn);
		}
		
		protected override function genAnimationInfo(_xml:XML):void
		{
			var intIndex:int;
			m_AnimNodeInfos[_xml.@id] = new CharacterAnimationNodeInfo(_xml.@name,_xml.@offsetX,_xml.@offsetY,_xml.@attackDistance);
			var _ar:Array = new Array();
			var nextid:int=-1
			var char:String;
			for each( var en:XML in _xml.*)
			{	 
				char = en.@NextId
				if(char!=""){
					nextid=en.@NextId
				}else{
					nextid=-1
				}
				_ar.push(new CharacterFrameNodeInfo(en.@num,en.@ax,en.@ay,en.@weaponId,en.@EffectId,en.@IsShake,en.@DefendId,en.@DefendEffectId,nextid,en.@sound));
				
			}
			if(_xml.@id>2000 && _xml.@id<2100)
			{
				intIndex = parseInt(_xml.@id.toString().substring(3,1));
				arrNormalAttackGroup[intIndex] += 1;
			}	
			m_FrameInfos[_xml.@id] = _ar;
		}
		
		public override function getNodeInfo(_animationId:int):BaseBmpNodeInfo
		{
			if(m_animationBmps[_animationId] == null)
				return null;
				
			return new CharacterBmpNodeInfo(_animationId,m_animationBmps[_animationId],m_AnimNodeInfos[_animationId],m_FrameInfos[_animationId]);
		}
		
		public function getAnimationInfo(_id:int):CharacterAnimationNodeInfo
		{
			if(m_AnimNodeInfos[_id]==null){
			}
			return m_AnimNodeInfos[_id];
		}
		
				
	}
}